package com.mitake.task.weekK;

import java.util.ArrayList;
import java.util.Map;

import com.mitake.parse.WeekK;
import com.mitake.parse.WeekK.WeekKItem;
import com.mitake.utils.Util;

public class WeekKCompareProcess {
	
	//public static ArrayList<WeekK[]> store =new ArrayList<WeekK[]>();
	
	public static WeekK[] data = null;
	
	public static void compare(WeekK[] weekKs){
		for(int i = 1, len = weekKs.length-1; i<len; i++){
			compareItem(weekKs, weekKs[i].weekKMap, weekKs[i+1].weekKMap);
		//	store.add(weekKs);
		}
		data = weekKs;
	}
	
	private static void compareItem(WeekK[] weekKs, Map<String,WeekKItem> weekK_1,Map<String,WeekKItem> weekK_2){
		for(String key : weekK_1.keySet()){
			 WeekKItem weekKItem = weekKs[0].weekKMap.get(key);
			 if(weekKItem == null){
				 weekKItem =new WeekKItem();
				 weekKs[0].weekKMap.put(key, weekKItem);
			 }
			if(Util.hasDifference(weekK_1.get(key).firstPrice, weekK_2.get(key).firstPrice)){
				weekKItem.lastPrice = "@";
			}
			if(Util.hasDifference(weekK_1.get(key).highPrice, weekK_2.get(key).highPrice)){
				weekKItem.lastPrice = "@";
			}
			if(Util.hasDifference(weekK_1.get(key).lowPrice, weekK_2.get(key).lowPrice)){
				weekKItem.lastPrice = "@";
			}
			if(Util.hasDifference(weekK_1.get(key).lastPrice, weekK_2.get(key).lastPrice)){
				weekKItem.lastPrice = "@";
			}
			if(Util.hasDifference(weekK_1.get(key).volume, weekK_2.get(key).volume)){
				weekKItem.volume = "@";
			}
			if(Util.hasDifference(weekK_1.get(key).reference, weekK_2.get(key).reference)){
				weekKItem.volume = "@";
			}
		}
	}
}
